using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FarseerPhysics.Dynamics;
using Microsoft.Xna.Framework;
using HappyFrogXna.Level;
using HappyFrogXna.DrawingSystem;
using HappyFrogXna.ScreenSystem;
using Microsoft.Xna.Framework.Graphics;
using FarseerPhysics.Factories;
using HappyFrogXna.ParticleSystem;
using HappyFrogXna.Miscellaneous;

namespace HappyFrogXna.Roles
{
    class Animal1 : CircleEntity, IAnimal
    {
        Vector2 _originalPos;

        public Animal1(World w, Vector2 pos)
            : base(w, pos)
        {
            _originalPos = pos;

            EntitySprite = new Sprite(GolbalXnaGadgetProvider.Instance.Content.Load<Texture2D>(@"Images\animal1"));
            float radius = ConvertUnits.ToSimUnits(EntitySprite.Height / 2);

            EntityBody = BodyFactory.CreateEllipse(_world, radius, radius, 8, 1f, pos);
            EntityBody.BodyType = BodyType.Dynamic;
            EntityBody.Rotation = 0.0f;
            EntityBody.Mass = 2f;
            EntityBody.Restitution = 0.2f;
            EntityBody.Friction = 0.6f;

            UserDate = new EntityUserData();
            UserDate.Name = "Animal1";
            UserDate.Type = EntityType.Animal;
            UserDate.HealthPoint = 35;
        }

        public override void RemoveMe()
        {
            ParticleCreator.Instance.CreateAnimalExplosion(ConvertUnits.ToDisplayUnits(EntityBody.Position));
            base.RemoveMe();
        }

        public bool HasBeenHitDown { get; set; }

        public bool TestBeenHitDown()
        {
            return (EntityBody.Position.Y > _originalPos.Y + 2 || Math.Abs(EntityBody.Position.X - _originalPos.X) > 4);
        }
    }
}
